package com.doge.walknovel.business.novel.viewholders

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.doge.wnpro.R
import com.doge.walknovel.api.model.NovelDetailInfo
import com.doge.walknovel.business.novel.COMMENTS_INPUT
import com.doge.walknovel.core.base.adapters.AdapterCallback
import com.doge.wnpro.databinding.CellNovelCommentsTopBinding
import com.doge.walknovel.utils.getString
import com.doge.walknovel.utils.setOnClickCallback

class NovelCommentsTopViewHolder(
    parent: ViewGroup,
    callback: AdapterCallback,
    private val binding: CellNovelCommentsTopBinding =
        CellNovelCommentsTopBinding.inflate(LayoutInflater.from(parent.context), parent, false),
) : RecyclerView.ViewHolder(binding.root) {
    init {
        binding.input.setOnClickCallback {
            callback.invoke(COMMENTS_INPUT, itemView.tag)
        }
    }

    fun bind(item: NovelDetailInfo) {
        itemView.tag = item
        binding.reviews.text = String.format(getString(R.string.xxx_reviews), item.totalCommentCount?.toString())
    }
}